package org.mspring.platform.api.rss.writers;

import java.util.HashMap;

import org.mspring.platform.api.rss.writers.defaults.RSS091;
import org.mspring.platform.api.rss.writers.defaults.RSS092;
import org.mspring.platform.api.rss.writers.defaults.RSS100;
import org.mspring.platform.api.rss.writers.defaults.RSS200;
import org.mspring.platform.api.rss.writers.defaults.RSS300;

/**
 * 
 * @author Gao Youbo
 * @since 2013年7月26日
 */
public class RSSWriterFactory {
    static HashMap<String, String> lookupTable = new HashMap<String, String>();

    private static String getClassName(String paramString) {
        String str = paramString;
        if (lookupTable.containsKey(paramString))
            str = (String) lookupTable.get(paramString);
        return str;
    }

    @SuppressWarnings("rawtypes")
    public static RSSWriter getWriter(String paramString) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        String str = getClassName(paramString);
        Class localClass = Class.forName(str);
        return (RSSWriter) localClass.newInstance();
    }

    static {
        lookupTable.put("rdf", RSS100.class.getName());
        lookupTable.put("100", RSS100.class.getName());
        lookupTable.put("1.0", RSS100.class.getName());
        lookupTable.put("rss", RSS092.class.getName());
        lookupTable.put("0.92", RSS092.class.getName());
        lookupTable.put("092", RSS092.class.getName());
        lookupTable.put("0.91", RSS091.class.getName());
        lookupTable.put("091", RSS091.class.getName());
        lookupTable.put("2.00", RSS200.class.getName());
        lookupTable.put("200", RSS200.class.getName());
        lookupTable.put("2.0", RSS200.class.getName());
        lookupTable.put("3.00", RSS300.class.getName());
        lookupTable.put("300", RSS300.class.getName());
        lookupTable.put("3.0", RSS300.class.getName());
    }
}